package net.jdm.common;

import java.util.Collection;
import java.util.HashSet;

public class HashSetExt<T> extends HashSet<T> {
	private static final long serialVersionUID = 1L;
	public HashSetExt(){
	}
	public HashSetExt(Collection<T> collection){
          super(collection);
	}
	public T getByHashCode(int hashCode){
        for(T t:this){
        	if(t.hashCode()==hashCode)
        		return t;
        }
        return null;
	}
	@Override
	public boolean equals(Object other) {
		if (other instanceof HashSetExt) {
			HashSetExt otherSet = (HashSetExt) other;
			return otherSet.hashCode()==hashCode();
		}
		return false;
	}
	@Override
	public String toString(){
		StringBuffer bf=new StringBuffer();
        for(T t:this){
        	bf.append(t.toString())
        	  .append(" ");
        }
        return bf.toString();
	}
	@Override
	public int hashCode(){
		return toString().hashCode();
	}
}
